(function(){
	// ================== 配置 BEGIN ===========================
	//私钥，后台管理员配给
	var privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMOZQanQTb3/fZ4iQJnDVrdpHU9fiVcSs/aHecjq5fzrbOM+SMeLlCg2sCBM8m1e3+1RE/YfM18kcQYjyR3x3nyXfJ0BeM+PJf7SzJ788TC6O/DhA7xgmSegNKa/6w8dAIBkd5jEarh/L8BPBkUTkwdF7ZvPZ9UPn0GKQ9KTyQlNAgMBAAECgYEAt6eLxwWGKXLeIP+qRnXqUzZIRgG/M9mkzkKwL92W6t6mk8wki/BbwVJwFzQIoHbnrK1nH751/sx5rzkkmpBCxHVn5Dc1+4ceHegulbwMRyX0U3T7Y7rOFyU+Agiie5evcSU+sHgBf7WxckQmsrZVCp8sAXKnhbJtMYCC6byQ1iUCQQD12kr71NjQaW0FXKjlstuEP5g55wgqkQqHaY/0uU9V73oN9c5p7L3QiiX/NxY6q0/XtajdvYYtkUdBEJiN1SbjAkEAy6v5RXY5IScPF0I3OIVp7po6yQGVp0DSb5eAQMO6BOZg/8EbMkiYplAzoFoBpF3Xp6Kvf+yyGLQyKtyo0y7WDwJBANB8RYo5fYN/Y8xgP3pKqo0DwPuZR/uQ8/TROBq36uddJYwhHuIEuRLXlFFRTbCDBjpO+tzPk7GguWQbxsLANzECQGJEQyykccPxGHLcW9BFbmrUtvAsd4wO1nlI23Rj+uhKTxqWjQyhwiTcJUyEoK4xKM+UyqAqD3Oj3WCYvkvGGTkCQQCfJWJElsI6fC8ED9kHcb3zBREYTnhwNXrH8jOP8KHJM5ECa7MbCeYO6DxuFsLEUyWgcOQWV3HyzMJ+H/muoWbJ";
	//公钥，后台管理员配给
	var publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDmUGp0E29/32eIkCZw1a3aR1PX4lXErP2h3nI6uX862zjPkjHi5QoNrAgTPJtXt/tURP2HzNfJHEGI8kd8d58l3ydAXjPjyX+0sye/PEwujvw4QO8YJknoDSmv+sPHQCAZHeYxGq4fy/ATwZFE5MHRe2bz2fVD59BikPSk8kJTQIDAQAB";
	// ================== 配置 END ===========================
	
	//
	var encryptutil = {};
	window.encryptutil = encryptutil;
	
	var privateKeyPem = '-----BEGIN PRIVATE KEY-----'+privateKey+'-----END PRIVATE KEY-----';
	var publicKeyPem = '-----BEGIN PUBLIC KEY-----'+publicKey+'-----END PUBLIC KEY-----';
	
	/**
	 * 加密数据
	 * @param {Object} data 被加密数据
	 * @return {string} 加密后的base64字符串
	 */
	encryptutil.encrypt = function(data){
		return hextob64(KJUR.crypto.Cipher.encrypt(data, KEYUTIL.getKey(publicKeyPem)));
	}
	
	/**
	 * 解密数据
	 * @param {Object} data 已加密数据，加密后的base64字符串/或加密后的16进制数据
	 * @return {string} 解密后的数据
	 */
	encryptutil.decrypt = function(data){
		try{
			return KJUR.crypto.Cipher.decrypt(data,KEYUTIL.getKey(privateKeyPem));
		}catch(e){
		}
		return  KJUR.crypto.Cipher.decrypt(b64tohex(data),KEYUTIL.getKey(privateKeyPem));
	}
	
	/**
	 * 数据签名
	 * @param {Object} data 被签名数据
	 */
	encryptutil.signature = function(data){
		var signature = new KJUR.crypto.Signature({alg:"MD5withRSA",prvkeypem:privateKeyPem});    
		signature.updateString(data);
		return hextob64(signature.sign());
	}
	
	/**
	 * 数据签名校验
	 * @param {Object} data 签名前的原始数据
	 * @param {Object} signature 数据签名
	 */
	encryptutil.signatureVf = function(data ,signature){
		var signatureVf = new KJUR.crypto.Signature({alg:"MD5withRSA",prvkeypem:publicKeyPem});
		signatureVf.updateString(data);
		return signatureVf.verify(b64tohex(sign));
	}
	
	
})();